package com.hitsz.global;

import com.hitsz.base.Cat;
import com.hitsz.base.Feed;

import java.util.ArrayList;

// 全局配置信息
public class Config {
    // 当前是否登录
    private boolean isLogin = false;

    // 决定表格页面的显示 cat or feed
    private String type = "";

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    // 用户信息
    private String username;
    private String user_id;

    // 猫的信息
    private ArrayList<Cat> cats;
    // 投喂记录
    private ArrayList<Feed> feeds;


    private Config() {}

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUser_id() {
        return user_id;
    }

    public void setUser_id(String user_id) {
        this.user_id = user_id;
    }

    public ArrayList<Cat> getCats() {
        return cats;
    }

    public void setCats(ArrayList<Cat> cats) {
        this.cats = cats;
    }

    public ArrayList<Feed> getFeeds() {
        return feeds;
    }

    public void setFeeds(ArrayList<Feed> feeds) {
        this.feeds = feeds;
    }

    private volatile static Config config;

    /**双重锁定检查
     */
    public static Config getInstance(){
        if(config == null){
            synchronized (Config.class){
                if(config == null){
                    System.out.println("new");
                    config = new Config();
                }
            }
        }
        return config;
    }

    // 设置当前状态为已登陆
    public void setLogin(boolean isLogin) { this.isLogin = isLogin; }
    public boolean isLogin()              { return this.isLogin;    }

}
